package co.edu.usbcali.csru.modelo.dto;

import co.edu.usbcali.csru.modelo.TipoVehiculo;
import co.edu.usbcali.csru.presentation.backingBeans.TipoVehiculoView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class TipoVehiculoDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String tpvNombre;
    private String tpvCodigo;
    private boolean rowSelected = false;
    private TipoVehiculoView tipoVehiculoView;
    private TipoVehiculo tipoVehiculo;

    public TipoVehiculo getTipoVehiculo() {
        return tipoVehiculo;
    }

    public String listener_update(ActionEvent e) {
        try {
            tipoVehiculoView.action_modifyWitDTO(((tpvCodigo == null) ||
                tpvCodigo.equals("")) ? null : new String(tpvCodigo),
                ((tpvNombre == null) || tpvNombre.equals("")) ? null
                                                              : new String(
                    tpvNombre));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        tpvCodigo = tipoVehiculo.getTpvCodigo().toString();
        tpvNombre = (tipoVehiculo.getTpvNombre() != null)
            ? tipoVehiculo.getTpvNombre().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Object details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        tpvCodigo = tipoVehiculo.getTpvCodigo().toString();
        tpvNombre = (tipoVehiculo.getTpvNombre() != null)
            ? tipoVehiculo.getTpvNombre().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setTipoVehiculo(TipoVehiculo tipoVehiculo) {
        this.tipoVehiculo = tipoVehiculo;
    }

    public TipoVehiculoView getTipoVehiculoView() {
        return tipoVehiculoView;
    }

    public void setTipoVehiculoView(TipoVehiculoView tipoVehiculoView) {
        this.tipoVehiculoView = tipoVehiculoView;
    }

    public String getTpvNombre() {
        return tpvNombre;
    }

    public void setTpvNombre(String tpvNombre) {
        this.tpvNombre = tpvNombre;
    }

    public String getTpvCodigo() {
        return tpvCodigo;
    }

    public void setTpvCodigo(String tpvCodigo) {
        this.tpvCodigo = tpvCodigo;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
